package collection02;

import java.util.ArrayList;
import java.util.Collection;

/**
 * @author Huangjin
 * @version 1.0
 * describe:
 * @date 2023/3/2 20:16
 */
public class CollectionDemo {
    public static void main(String[] args) {
        /*
        Collection c = new ArrayList();
        c.add("One");
        c.add("Two");
        c.add("Three");
        c.add("Four");
        c.add("Five");
        System.out.println(c);
        Point p = new Point(1,2);
        boolean contains = c.contains(p);
        System.out.println("是否包含："+contains);
        c.remove(p);
        System.out.println(c);

        //集合中存放的是元素的引用
        Collection cc = new ArrayList();
        Point pp = new Point(1,2);
        //将pp添加到cc中-----将pp的引用装到了cc中
        cc.add(pp);
        System.out.println("pp:"+pp);
        System.out.println("cc:"+cc);

        pp.setX(100);
        System.out.println("pp:"+pp);
        System.out.println("cc:"+cc);

         */
        Collection c = new ArrayList();
        c.add("One");
        c.add("Two");
        c.add("Three");
        c.add("Four");
        c.add("Five");
        System.out.println(c);
        System.out.println("size:"+ c.size());
        System.out.println("是否为空集："+c.isEmpty());
        //清空集合
        c.clear();
        System.out.println("集合已经清空");
        System.out.println(c);
        System.out.println("size:"+c.size());
        System.out.println("是否为空集："+c.isEmpty());
    }
}
